<?php
/*
Plugin Name: e-Overtime
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: This describes my plugin in a short sentence
Version: 1.5
Author: Ong Zhi Xian
Author URI: http://URI_Of_The_Plugin_Author
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Domain Path: /languages
Text Domain: my-toolset
*/

/*
 * Add all your sections, fields and settings during admin_init
 */
 
function wporg_settings_api_init() {
    // Add the section to reading settings so we can add our fields to it
    add_settings_section(
        'wporg_setting_section',
        'Example settings section in reading',
        'wporg_setting_section_callback_function',
        'reading'
    );
 
    // Add the field with the names and function to use for our new settings, put it in our new section
    add_settings_field(
        'wporg_setting_name',
        'Example setting Name',
        'wporg_setting_callback_function',
        'reading',
        'wporg_setting_section'
    );
 
    // Register our setting in the "reading" settings section
    register_setting( 'reading', 'wporg_setting_name' );
}
add_action( 'admin_init', 'wporg_settings_api_init' );
 
/*
 * Settings section callback function
 */
 
function wporg_setting_section_callback_function() {
    echo '<p>Intro text for our settings section</p>';
}
 
/*
 * Callback function for our example setting
 */
 
function wporg_setting_callback_function() {
    $setting = esc_attr( get_option( 'wporg_setting_name' ) );
    echo "<input type='text' name='wporg_setting_name' value='$setting' />";
}

////////////////////////////////////////////////////////////////////////////////
//INIT
function pluginprefix_setup_post_types() {
 
    // Register our "book" custom post type
    register_post_type( 'book', array( 'public' => 'true' ) );
 
}
add_action( 'init', 'pluginprefix_setup_post_types' );

////////////////////////////////////////////////////////////////////////////////
//INSTALL
function pluginprefix_install() {
 
    // Trigger our function that registers the custom post type
    pluginprefix_setup_post_types();
 
    // Clear the permalinks after the post type has been registered
    flush_rewrite_rules();
 
}
register_activation_hook( __FILE__, 'pluginprefix_install' );

////////////////////////////////////////////////////////////////////////////////
//DEACTIVATION
function pluginprefix_deactivation() {
 
    // Our post type will be automatically removed, so no need to unregister it
 
    // Clear the permalinks to remove our post type's rules
    flush_rewrite_rules();
 
}
register_deactivation_hook( __FILE__, 'pluginprefix_deactivation' );


////////////////////////////////////////////////////////////////////////////////
//UNINSTALL
function pluginprefix_uninstall() {
    //$option_name = 'plugin_option_name';
     
    //delete_option( $option_name );
     
    // For site options in Multisite
    //delete_site_option( $option_name );  
     
    // Drop a custom db table
    global $wpdb;
    //$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}mytable" );
}
register_uninstall_hook( __FILE__, 'pluginprefix_deactivation' );


////////////////////////////////////////////////////////////////////////////////
//IS_ADMIN only code
if ( is_admin ) {
     // We are in admin mode
     //require_once( dirname(__file__).'/admin/myplugin_admin.php' );
}
?>
